
import os
import subprocess

def close_python_processes():
    try:
        # 使用taskkill命令强制关闭所有python.exe进程
        subprocess.run(['taskkill', '/F', '/IM', 'python.exe'], check=True)
        print("已成功关闭所有python.exe进程")
    except subprocess.CalledProcessError:
        print("没有找到正在运行的python.exe进程")
    except Exception as e:
        print(f"发生错误: {str(e)}")

if __name__ == '__main__':
    close_python_processes()
